{
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "# Linear Regression with Nomalize Data"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "import pandas as pd\n",
        "import matplotlib.pyplot as plt\n",
        "\n",
        "import warnings\n",
        "warnings.filterwarnings(\"ignore\")\n",
        "\n",
        "# yahoo finance is used to fetch data \n",
        "import yfinance as yf\n",
        "yf.pdr_override()"
      ],
      "outputs": [],
      "execution_count": 1,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-05-19T13:28:53.963Z",
          "iopub.execute_input": "2022-05-19T13:28:53.968Z",
          "shell.execute_reply": "2022-05-19T13:28:54.430Z",
          "iopub.status.idle": "2022-05-19T13:28:54.437Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# input\n",
        "symbol = 'AMD'\n",
        "start = '2007-01-01'\n",
        "end = '2021-12-31'\n",
        "\n",
        "# Read data \n",
        "dataset = yf.download(symbol,start,end)\n",
        "\n",
        "# View Columns\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[*********************100%***********************]  1 of 1 completed\n"
          ]
        },
        {
          "output_type": "execute_result",
          "execution_count": 2,
          "data": {
            "text/plain": "                 Open       High        Low      Close  Adj Close    Volume\nDate                                                                       \n2007-01-03  20.080000  20.400000  19.350000  19.520000  19.520000  28350300\n2007-01-04  19.660000  19.860001  19.320000  19.790001  19.790001  23652500\n2007-01-05  19.540001  19.910000  19.540001  19.709999  19.709999  15902400\n2007-01-08  19.709999  19.860001  19.370001  19.469999  19.469999  15814800\n2007-01-09  19.450001  19.709999  19.370001  19.650000  19.650000  14494200",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2007-01-03</th>\n      <td>20.080000</td>\n      <td>20.400000</td>\n      <td>19.350000</td>\n      <td>19.520000</td>\n      <td>19.520000</td>\n      <td>28350300</td>\n    </tr>\n    <tr>\n      <th>2007-01-04</th>\n      <td>19.660000</td>\n      <td>19.860001</td>\n      <td>19.320000</td>\n      <td>19.790001</td>\n      <td>19.790001</td>\n      <td>23652500</td>\n    </tr>\n    <tr>\n      <th>2007-01-05</th>\n      <td>19.540001</td>\n      <td>19.910000</td>\n      <td>19.540001</td>\n      <td>19.709999</td>\n      <td>19.709999</td>\n      <td>15902400</td>\n    </tr>\n    <tr>\n      <th>2007-01-08</th>\n      <td>19.709999</td>\n      <td>19.860001</td>\n      <td>19.370001</td>\n      <td>19.469999</td>\n      <td>19.469999</td>\n      <td>15814800</td>\n    </tr>\n    <tr>\n      <th>2007-01-09</th>\n      <td>19.450001</td>\n      <td>19.709999</td>\n      <td>19.370001</td>\n      <td>19.650000</td>\n      <td>19.650000</td>\n      <td>14494200</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 2,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-05-19T13:28:54.442Z",
          "iopub.execute_input": "2022-05-19T13:28:54.445Z",
          "iopub.status.idle": "2022-05-19T13:28:56.231Z",
          "shell.execute_reply": "2022-05-19T13:28:56.259Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "dataset['Open_Close'] = (dataset['Open'] - dataset['Adj Close'])/dataset['Open']\n",
        "dataset['High_Low'] = (dataset['High'] - dataset['Low'])/dataset['Low']\n",
        "dataset['Increase_Decrease'] = np.where(dataset['Volume'].shift(-1) > dataset['Volume'],1,0)\n",
        "dataset['Buy_Sell_on_Open'] = np.where(dataset['Open'].shift(-1) > dataset['Open'],1,0)\n",
        "dataset['Buy_Sell'] = np.where(dataset['Adj Close'].shift(-1) > dataset['Adj Close'],1,0)\n",
        "dataset['Returns'] = dataset['Adj Close'].pct_change()\n",
        "dataset = dataset.dropna()\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 3,
          "data": {
            "text/plain": "                 Open       High        Low      Close  Adj Close    Volume  \\\nDate                                                                          \n2007-01-04  19.660000  19.860001  19.320000  19.790001  19.790001  23652500   \n2007-01-05  19.540001  19.910000  19.540001  19.709999  19.709999  15902400   \n2007-01-08  19.709999  19.860001  19.370001  19.469999  19.469999  15814800   \n2007-01-09  19.450001  19.709999  19.370001  19.650000  19.650000  14494200   \n2007-01-10  19.639999  20.020000  19.500000  20.010000  20.010000  19783200   \n\n            Open_Close  High_Low  Increase_Decrease  Buy_Sell_on_Open  \\\nDate                                                                    \n2007-01-04   -0.006612  0.027950                  0                 0   \n2007-01-05   -0.008700  0.018935                  0                 1   \n2007-01-08    0.012177  0.025297                  0                 0   \n2007-01-09   -0.010283  0.017553                  1                 1   \n2007-01-10   -0.018839  0.026667                  1                 1   \n\n            Buy_Sell   Returns  \nDate                            \n2007-01-04         0  0.013832  \n2007-01-05         0 -0.004043  \n2007-01-08         1 -0.012177  \n2007-01-09         1  0.009245  \n2007-01-10         1  0.018321  ",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>Open_Close</th>\n      <th>High_Low</th>\n      <th>Increase_Decrease</th>\n      <th>Buy_Sell_on_Open</th>\n      <th>Buy_Sell</th>\n      <th>Returns</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2007-01-04</th>\n      <td>19.660000</td>\n      <td>19.860001</td>\n      <td>19.320000</td>\n      <td>19.790001</td>\n      <td>19.790001</td>\n      <td>23652500</td>\n      <td>-0.006612</td>\n      <td>0.027950</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0.013832</td>\n    </tr>\n    <tr>\n      <th>2007-01-05</th>\n      <td>19.540001</td>\n      <td>19.910000</td>\n      <td>19.540001</td>\n      <td>19.709999</td>\n      <td>19.709999</td>\n      <td>15902400</td>\n      <td>-0.008700</td>\n      <td>0.018935</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>-0.004043</td>\n    </tr>\n    <tr>\n      <th>2007-01-08</th>\n      <td>19.709999</td>\n      <td>19.860001</td>\n      <td>19.370001</td>\n      <td>19.469999</td>\n      <td>19.469999</td>\n      <td>15814800</td>\n      <td>0.012177</td>\n      <td>0.025297</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.012177</td>\n    </tr>\n    <tr>\n      <th>2007-01-09</th>\n      <td>19.450001</td>\n      <td>19.709999</td>\n      <td>19.370001</td>\n      <td>19.650000</td>\n      <td>19.650000</td>\n      <td>14494200</td>\n      <td>-0.010283</td>\n      <td>0.017553</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.009245</td>\n    </tr>\n    <tr>\n      <th>2007-01-10</th>\n      <td>19.639999</td>\n      <td>20.020000</td>\n      <td>19.500000</td>\n      <td>20.010000</td>\n      <td>20.010000</td>\n      <td>19783200</td>\n      <td>-0.018839</td>\n      <td>0.026667</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.018321</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 3,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-05-19T13:28:56.237Z",
          "iopub.execute_input": "2022-05-19T13:28:56.241Z",
          "shell.execute_reply": "2022-05-19T13:28:56.263Z",
          "iopub.status.idle": "2022-05-19T13:28:56.276Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "X = dataset[['Open', 'High', 'Low','Volume', 'Open_Close', 'High_Low', 'Returns']]\n",
        "y = dataset['Adj Close']"
      ],
      "outputs": [],
      "execution_count": 4,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-05-19T13:28:56.282Z",
          "iopub.execute_input": "2022-05-19T13:28:56.287Z",
          "iopub.status.idle": "2022-05-19T13:28:56.293Z",
          "shell.execute_reply": "2022-05-19T13:28:56.316Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn import preprocessing\n",
        "\n",
        "# normalize the data attributes\n",
        "normalized_X = preprocessing.normalize(X)"
      ],
      "outputs": [],
      "execution_count": 5,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-05-19T13:28:56.299Z",
          "iopub.execute_input": "2022-05-19T13:28:56.302Z",
          "iopub.status.idle": "2022-05-19T13:28:58.373Z",
          "shell.execute_reply": "2022-05-19T13:28:58.407Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "normalized_X.shape"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 6,
          "data": {
            "text/plain": "(3775, 7)"
          },
          "metadata": {}
        }
      ],
      "execution_count": 6,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-05-19T13:28:58.378Z",
          "iopub.execute_input": "2022-05-19T13:28:58.381Z",
          "iopub.status.idle": "2022-05-19T13:28:58.390Z",
          "shell.execute_reply": "2022-05-19T13:28:58.410Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.model_selection import train_test_split\n",
        "X_train, X_test, y_train, y_test = train_test_split(normalized_X, y, \n",
        "                                   test_size=0.4, random_state=101)"
      ],
      "outputs": [],
      "execution_count": 7,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-05-19T13:28:58.397Z",
          "iopub.execute_input": "2022-05-19T13:28:58.403Z",
          "iopub.status.idle": "2022-05-19T13:28:58.433Z",
          "shell.execute_reply": "2022-05-19T13:28:58.450Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.linear_model import LinearRegression\n",
        "\n",
        "lm = LinearRegression()\n",
        "lm.fit(X_train,y_train)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 8,
          "data": {
            "text/plain": "LinearRegression()"
          },
          "metadata": {}
        }
      ],
      "execution_count": 8,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-05-19T13:28:58.438Z",
          "iopub.execute_input": "2022-05-19T13:28:58.442Z",
          "iopub.status.idle": "2022-05-19T13:28:58.497Z",
          "shell.execute_reply": "2022-05-19T13:28:58.529Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "coeff_df = pd.DataFrame(lm.coef_,X.columns,columns={'Coefficient'})\n",
        "coeff_df"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 9,
          "data": {
            "text/plain": "             Coefficient\nOpen       -1.029206e+08\nHigh        8.942137e+08\nLow        -7.744942e+08\nVolume      6.935967e+11\nOpen_Close  2.269954e+08\nHigh_Low   -3.568859e+09\nReturns     1.210413e+08",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Coefficient</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Open</th>\n      <td>-1.029206e+08</td>\n    </tr>\n    <tr>\n      <th>High</th>\n      <td>8.942137e+08</td>\n    </tr>\n    <tr>\n      <th>Low</th>\n      <td>-7.744942e+08</td>\n    </tr>\n    <tr>\n      <th>Volume</th>\n      <td>6.935967e+11</td>\n    </tr>\n    <tr>\n      <th>Open_Close</th>\n      <td>2.269954e+08</td>\n    </tr>\n    <tr>\n      <th>High_Low</th>\n      <td>-3.568859e+09</td>\n    </tr>\n    <tr>\n      <th>Returns</th>\n      <td>1.210413e+08</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 9,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-05-19T13:28:58.503Z",
          "iopub.execute_input": "2022-05-19T13:28:58.506Z",
          "iopub.status.idle": "2022-05-19T13:28:58.515Z",
          "shell.execute_reply": "2022-05-19T13:28:58.531Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "y_pred = lm.predict(X_test)\n",
        "plt.scatter(y_test,y_pred)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 10,
          "data": {
            "text/plain": "<matplotlib.collections.PathCollection at 0x221d72574e0>"
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": "<Figure size 432x288 with 1 Axes>",
            "image/png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fuLf772o6c9GfBL5I593oM8dc5w/y7FUrL+2+GL4E/BHdd8rHUNOlwEx37PYCZ6yVcQN+CXgIeAD4P3SuGhjLuNH5ysSvAsfohM9P9RsnOm9m/5fusXEAmB5DbV+iM687dzx8aN72u7q1HQT+1WrXtmD9wzz7ZueqjVufMdsA/H739fZZ4HWjGDM/oi9JjVvLUyuSpGUwyCWpcQa5JDXOIJekxhnkktQ4g1ySGmeQS1Lj/j/uQ6odsCNyngAAAABJRU5ErkJggg==\n"
          },
          "metadata": {
            "needs_background": "light"
          }
        }
      ],
      "execution_count": 10,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-05-19T13:28:58.519Z",
          "iopub.execute_input": "2022-05-19T13:28:58.523Z",
          "shell.execute_reply": "2022-05-19T13:28:58.631Z",
          "iopub.status.idle": "2022-05-19T13:28:58.635Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn import metrics\n",
        "print('MAE:', metrics.mean_absolute_error(y_test, y_pred))\n",
        "print('MSE:', metrics.mean_squared_error(y_test, y_pred))\n",
        "print('RMSE:', np.sqrt(metrics.mean_squared_error(y_test, y_pred)))"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "MAE: 459329170.9301753\n",
            "MSE: 3.185847551457256e+20\n",
            "RMSE: 17848942689.854927\n"
          ]
        }
      ],
      "execution_count": 11,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-05-19T13:28:58.640Z",
          "iopub.execute_input": "2022-05-19T13:28:58.643Z",
          "iopub.status.idle": "2022-05-19T13:28:58.651Z",
          "shell.execute_reply": "2022-05-19T13:28:58.658Z"
        }
      }
    }
  ],
  "metadata": {
    "kernel_info": {
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.6.13",
      "mimetype": "text/x-python",
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "pygments_lexer": "ipython3",
      "nbconvert_exporter": "python",
      "file_extension": ".py"
    },
    "kernelspec": {
      "name": "python3",
      "language": "python",
      "display_name": "Python 3"
    },
    "nteract": {
      "version": "0.28.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}